#函数
#求1-100和
theSum = 0
for i in range(1,101):
    theSum += i
print(theSum)
#求1-1000的和
theSum = 0
for i in range(1,1001):
    theSum += i
print(theSum)
#代码复用
def calc_sum(beg,end):
    theSum = 0
    for i in range(beg,end+1):
        theSum += i
    print(theSum)

calc_sum(1,100)
calc_sum(300,400)